<?php

namespace app\common\model;

use app\common\model\BaseModel;
use think\model\concern\SoftDelete;

class Car extends BaseModel
{

    use SoftDelete;

    

    // 表名
    protected $name = 'car';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [

    ];


	public function getStatusList()
	{
		return ['1' => __('启用'), '2' => __('禁用')];
	}


	public static function getGearList($type = null)
	{
		$data = ['1' => __('手动'), '2' => __('自动')];
		if ($type){
			return $data[$type];
		}else{
			return $data;
		}
	}

    public static function getDriveList($drive = null)
    {
        $data = ['1' => __('两驱'), '2' => __('四驱')];
        if ($drive){
            return $data[$drive];
        }else{
            return $data;
        }
    }

    public static function getCarList($where = []){
	    return self::where($where)->order('id', 'desc')->column('car_name', 'id');
    }


    public function brand(){
        return $this->hasOne('car_cate','id','brand_id')->joinType('left');
    }

    public function model(){
        return $this->hasOne('car_cate','id','model_id')->joinType('left');
    }





}
